<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
<%@ Import Namespace="Ornament.Web" %>
<script type="text/C#" runat="server">

    private void Build(SiteMapNodeCollection childNodes, bool first)
    {
        foreach (SiteMapNode node in childNodes)
        {
            if (node.ChildNodes.Count == 0)
            {
                Response.Write(String.Format(("<li><a href='{0}'>{1}</a></li>"), node.Url, node.Title));
            }
            else
            {
                string clz = first ? "child" : "";
                Response.Write(String.Format(("<li><a href='{0}' class='" + clz + "'>{1}</a>"), node.Url, node.Title));
                Response.Write("<ul>");
                this.Build(node.ChildNodes, false);
                Response.Write("</ul>");
                Response.Write("</li>");
            }
        }
    }

</script>
<ul>
    <%
        if (OrnamentContext.Current.CurrentUser != null)
        {
            Build(SiteMap.RootNode.ChildNodes[1].ChildNodes, true);
        }
    %>
</ul>
